import 'package:vista/shared/models/base_frame.dart';

/// 教程视频画面
/// 存储摄影教程视频信息，如摄影中的教程画面般记录教学内容
class TutorialVideo extends BaseFrame {
  final String id; // 视频ID
  final String title; // 视频标题
  final String videoPath; // 视频路径
  final String coverImage; // 封面图
  final int viewCount; // 查看次数
  final DateTime createdAt; // 创建时间

  const TutorialVideo({
    required this.id,
    required this.title,
    required this.videoPath,
    required this.coverImage,
    required this.viewCount,
    required this.createdAt,
  });

  /// 从JSON创建教程视频画面
  factory TutorialVideo.fromJson(Map<String, dynamic> json) {
    return TutorialVideo(
      id: json['id'] as String,
      title: json['title'] as String,
      videoPath: json['videoPath'] as String,
      coverImage: json['coverImage'] as String? ?? '',
      viewCount: json['viewCount'] as int? ?? 0,
      createdAt: DateTime.parse(json['createdAt'] as String),
    );
  }

  @override
  List<Object?> get props => [
    id,
    title,
    videoPath,
    coverImage,
    viewCount,
    createdAt,
  ];

  @override
  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'title': title,
      'videoPath': videoPath,
      'coverImage': coverImage,
      'viewCount': viewCount,
      'createdAt': createdAt.toIso8601String(),
    };
  }
}
